Migrate tests from MSTest to xUnit and clean up test infrastructure#193
Migrate tests from MSTest to xUnit and clean up test infrastructure#193
Conversation
Co-authored-by: gfs <98900+gfs@users.noreply.github.com>
Co-authored-by: gfs <98900+gfs@users.noreply.github.com>
|
@copilot try again please |
…ectedException, duplicate DataRows, add parallelization, use Assert.HasCount/IsEmpty/IsGreaterThan, add CancellationToken support. Update pipeline to use standard trx logger with results directory. Co-authored-by: gfs <98900+gfs@users.noreply.github.com>
Fixed all MSTest warnings in commit cca4e14. The changes include:
Build now succeeds with 0 warnings and 0 errors. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This pull request addresses MSTest warnings in the test output and fixes the Azure DevOps pipeline test result handling. The changes modernize the test code to use newer MSTest 3.x assertion methods and configuration patterns, and ensure test results are properly published to the pipeline.
Changes:
- Fixed MSTest warnings (MSTEST0001, 0006, 0037, 0039, 0042, 0044, 0049) by replacing deprecated patterns with modern MSTest 3.x equivalents
- Updated Azure Pipelines YAML files to properly specify test result output location and format
- Added test parallelization configuration and cancellation token support for async tests
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| RecursiveExtractor.Tests/AssemblyInfo.cs | Added assembly-level Parallelize attribute for MSTEST0001 compliance |
| RecursiveExtractor.Tests/ExtractorTests/BaseExtractorTestClass.cs | Added TestContext property for MSTEST0049 compliance |
| RecursiveExtractor.Tests/ExtractorTests/CustomExtractorTests.cs | Added TestContext property; replaced Assert.AreEqual with Assert.HasCount/IsEmpty/IsGreaterThan for MSTEST0037 |
| RecursiveExtractor.Tests/ExtractorTests/DisposeBehaviorTests.cs | Replaced DataTestMethod with TestMethod; removed duplicate DataRow attributes; replaced Assert.ThrowsException with Assert.ThrowsExactly for MSTEST0044, 0042, 0039 |
| RecursiveExtractor.Tests/ExtractorTests/EncryptedArchiveTests.cs | Replaced DataTestMethod with TestMethod for MSTEST0044 |
| RecursiveExtractor.Tests/ExtractorTests/FilterTests.cs | Replaced DataTestMethod with TestMethod for MSTEST0044 |
| RecursiveExtractor.Tests/ExtractorTests/MiniMagicTests.cs | Replaced DataTestMethod with TestMethod for MSTEST0044 |
| RecursiveExtractor.Tests/ExtractorTests/MiscTests.cs | Added TestContext property; replaced DataTestMethod with TestMethod; replaced Assert.AreEqual with Assert.HasCount; added CancellationToken to ToListAsync calls for MSTEST0049, 0044, 0037 |
| RecursiveExtractor.Tests/ExtractorTests/TestQuinesAndSlip.cs | Replaced ExpectedException with Assert.ThrowsExactly/ThrowsExactlyAsync; added CancellationToken to ToListAsync calls for MSTEST0006, 0049 |
| RecursiveExtractor.Tests/ExtractorTests/TimeOutTests.cs | Replaced DataTestMethod with TestMethod; removed duplicate DataRow attributes; replaced Assert.ThrowsException with Assert.ThrowsExactly/ThrowsExactlyAsync for MSTEST0044, 0042, 0039 |
| RecursiveExtractor.Tests/SanitizePathTests.cs | Replaced DataTestMethod with TestMethod for MSTEST0044 |
| Pipelines/recursive-extractor-pr.yml | Updated dotnetTestArgs to properly specify TRX output location for test result publishing |
| Pipelines/recursive-extractor-release.yml | Updated dotnetTestArgs to properly specify TRX output location for test result publishing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot this change breaks the PR gates - now see |
…sing error Co-authored-by: gfs <98900+gfs@users.noreply.github.com>
Fixed in bdfa42c. Reverted the pipeline |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@copilot I still see |
…ectory Co-authored-by: gfs <98900+gfs@users.noreply.github.com>
Fixed in 1e3c7b2. Changed the pipeline |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (3)
RecursiveExtractor.Tests/ExtractorTests/DisposeBehaviorTests.cs:150
- Poor error handling: empty catch block.
catch (DirectoryNotFoundException) { }
RecursiveExtractor.Tests/ExtractorTests/DisposeBehaviorTests.cs:174
- Poor error handling: empty catch block.
catch (DirectoryNotFoundException) { }
RecursiveExtractor.Tests/ExtractorTests/DisposeBehaviorTests.cs:182
- Poor error handling: empty catch block.
catch (DirectoryNotFoundException) { }
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RecursiveExtractor.Tests/ExtractorTests/BaseExtractorTestClass.cs
Outdated
Show resolved
Hide resolved
Test classes now use IClassFixture<BaseExtractorTestClass> for improved setup/teardown and isolation. BaseExtractorTestClass implements IDisposable for proper cleanup. Added documentation and updated using statements. Minor formatting and code organization improvements.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (3)
RecursiveExtractor.Tests/ExtractorTests/DisposeBehaviorTests.cs:150
- Poor error handling: empty catch block.
catch (DirectoryNotFoundException) { }
RecursiveExtractor.Tests/ExtractorTests/DisposeBehaviorTests.cs:174
- Poor error handling: empty catch block.
catch (DirectoryNotFoundException) { }
RecursiveExtractor.Tests/ExtractorTests/DisposeBehaviorTests.cs:182
- Poor error handling: empty catch block.
catch (DirectoryNotFoundException) { }
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RecursiveExtractor.Tests/ExtractorTests/BaseExtractorTestClass.cs
Outdated
Show resolved
Hide resolved
RecursiveExtractor.Tests/ExtractorTests/BaseExtractorTestClass.cs
Outdated
Show resolved
Hide resolved
Replaced individual class fixtures with a shared ExtractorTestCollection using Xunit's [CollectionDefinition] and ICollectionFixture<BaseExtractorTestClass>. This ensures all extractor test classes share a single fixture instance, preventing race conditions and premature deletion of shared resources during parallel test execution.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Replaced IEnumerable<object[]> with TheoryData<string> for ZipSlipNames and QuineBombNames, improving type safety and clarity in parameterized tests. Removed unused using directives for cleaner code.
…microsoft/RecursiveExtractor into copilot/resolve-mstest-warnings
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (3)
RecursiveExtractor.Tests/ExtractorTests/DisposeBehaviorTests.cs:151
- Poor error handling: empty catch block.
catch (DirectoryNotFoundException) { }
RecursiveExtractor.Tests/ExtractorTests/DisposeBehaviorTests.cs:175
- Poor error handling: empty catch block.
catch (DirectoryNotFoundException) { }
RecursiveExtractor.Tests/ExtractorTests/DisposeBehaviorTests.cs:183
- Poor error handling: empty catch block.
catch (DirectoryNotFoundException) { }
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| [TestClass] | ||
| public class FilterTests : BaseExtractorTestClass | ||
| [Collection(ExtractorTestCollection.Name)] |
There was a problem hiding this comment.
This test class doesn't use TestPathHelpers.GetFreshTestDirectory() and doesn't need to be in the ExtractorTestCollection. The Collection attribute can be removed to allow this test class to run in parallel with other test classes. The Collection is primarily needed for test classes that share the test directory cleanup fixture (currently only ExpectedNumFilesTests and DisposeBehaviorTests).
| [Collection(ExtractorTestCollection.Name)] |
|
|
||
| [TestClass] | ||
| public class MiniMagicTests : BaseExtractorTestClass | ||
| [Collection(ExtractorTestCollection.Name)] |
There was a problem hiding this comment.
This test class doesn't use TestPathHelpers.GetFreshTestDirectory() and doesn't need to be in the ExtractorTestCollection. The Collection attribute can be removed to allow this test class to run in parallel with other test classes. The Collection is primarily needed for test classes that share the test directory cleanup fixture (currently only ExpectedNumFilesTests and DisposeBehaviorTests).
| [Collection(ExtractorTestCollection.Name)] |
|
|
||
| [TestClass] | ||
| public class TimeOutTests : BaseExtractorTestClass | ||
| [Collection(ExtractorTestCollection.Name)] |
There was a problem hiding this comment.
This test class doesn't use TestPathHelpers.GetFreshTestDirectory() and doesn't need to be in the ExtractorTestCollection. The Collection attribute can be removed to allow this test class to run in parallel with other test classes. The Collection is primarily needed for test classes that share the test directory cleanup fixture (currently only ExpectedNumFilesTests and DisposeBehaviorTests).
| [Collection(ExtractorTestCollection.Name)] |
|
|
||
| [TestClass] | ||
| public class TestQuinesAndSlip : BaseExtractorTestClass | ||
| [Collection(ExtractorTestCollection.Name)] |
There was a problem hiding this comment.
This test class doesn't use TestPathHelpers.GetFreshTestDirectory() and doesn't need to be in the ExtractorTestCollection. The Collection attribute can be removed to allow this test class to run in parallel with other test classes. The Collection is primarily needed for test classes that share the test directory cleanup fixture (currently only ExpectedNumFilesTests and DisposeBehaviorTests).
| [Collection(ExtractorTestCollection.Name)] |
|
|
||
| [TestClass] | ||
| public class EncryptedArchiveTests : BaseExtractorTestClass | ||
| [Collection(ExtractorTestCollection.Name)] |
There was a problem hiding this comment.
This test class doesn't use TestPathHelpers.GetFreshTestDirectory() and doesn't need to be in the ExtractorTestCollection. The Collection attribute can be removed to allow this test class to run in parallel with other test classes. The Collection is primarily needed for test classes that share the test directory cleanup fixture (currently only ExpectedNumFilesTests and DisposeBehaviorTests).
| [Collection(ExtractorTestCollection.Name)] |
| } | ||
| if (Directory.Exists(copyDirectory)) { | ||
| Directory.Delete(copyDirectory, true); | ||
| catch (DirectoryNotFoundException) { } |
There was a problem hiding this comment.
Poor error handling: empty catch block.
This issue also appears in the following locations of the same file:
- line 151
- line 175
- line 183
Suppressed CS1685 warning in the test project due to a RuntimeHelpers polyfill conflict on net48. Removed DiscUtils Btrfs, HfsPlus, SquashFs, and Xfs package references from the test project - they are already imported when needed in the main project which is then imported into the test project to test it
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Removed the [Collection(ExtractorTestCollection.Name)] attribute from EncryptedArchiveTests, FilterTests, MiniMagicTests, TestQuinesAndSlip, and TimeOutTests. These test classes are no longer grouped in a shared test collection - the collection was used to protect against premature deletion of the temp directory but these tsts don't extract files to disc.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Index and Range polyfills were removed since they are now provided by Microsoft.Bcl.Memory as a transitive dependency. The file retains only the RuntimeHelpers.GetSubArray polyfill for array range syntax support on netstandard2.0.
Added the null-forgiving operator (`!`) to the `name` variable in the `while` loop condition to suppress potential null reference warnings. `name` is expected to be non-null at this point in the code becauses of the previous IsNullorEmpty check - however that isn't tagged on netstandard2.0.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Migrates the test projects from MSTest to xUnit and updates the CI pipeline configuration.
Test Framework Migration (MSTest → xUnit)
[TestMethod]→[Fact],[DataRow]→[Theory]/[InlineData]/[MemberData]Pipeline Updates
dotnetTestArgsto use--settings coverlet.runsettings --collect:"XPlat Code Coverage"coverlet.runsettingsfile to configure coverage output format (cobertura,opencover) for ADO pipeline compatibilityPublishCodeCoverageResults@2task viapostTestparameter to publish code coverage results to Azure DevOpsCode Cleanup
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.